import request from '../request'

const user = {

  setAvatar: (avatarPath)=>{
    return request({
      url: '/app/user/profile',
      method: 'post',
      header:{ allData: true},
      data: { avatar: avatarPath }
    })
  },

  setProfile: (data)=>{
    return request({
      url: '/app/user/profile',
      method: 'post',
      data: data
    })
  },

  getProfile: (id)=>{
    let url = '/app/user/profile/'
    if(!wx.$isNull(id)){
      url = url + id
    }
    return request({
      url: url,
      method: 'get'
    })
  },

  getPhotos: (data)=>{
    return request({
      url: '/app/user/photo',
      method: 'get',
      data: data
    })
  },

  /** 新增照片 */
  setPhoto: (data)=>{
    return request({
      header:{ allData: true},
      url: '/app/user/photo',
      method: 'post',
      data: data
    })
  },

  delPhoto: (id)=>{
    return request({
      url: '/app/user/photo/' + id,
      method: 'delete'
    })
  },

  getPhotosCount: ()=>{
    return request({
      url: '/app/user/photo/count',
      method: 'get'
    }) 
  },
  /** 更新照片信息 */
  setPhotoInfo: (data)=>{
    return request({
      url: '/app/user/photo',
      method: 'put',
      data: data
    })  
  },
  getUserList: (data,pageNum, pageSize)=>{
    data.pageNum = pageNum,
    data.pageSize = pageSize
    console.log(data)
    return request({
      header:{ allData: true },
      url: '/app/user/list',
      method: 'get',
      data: data
    }) 
  },

  getPush: (sex)=>{
    return request({
      url: '/app/user/push/' + sex,
      method: 'get'
    })
  },

  getPushUser: (userId)=>{
    return request({
      url: '/app/user/push/user/' + userId,
      method: 'get'
    })
  }




}
export default user